package com.zfh.service;

import java.util.List;

import com.zfh.dao.UserDAO;
import com.zfh.dao.UserDAOImpl1;
import com.zfh.dao.UserDAOImpl2;
import com.zfh.entity.User;

public class UserServiceImpl1 implements UserService {
	
//	private UserDAO userDAO = new UserDAOImpl1();
	private UserDAO userDAO = new UserDAOImpl2();

	@Override
	public List<User> getAll() {
		List<User> users = null;
		try {
			users = userDAO.getAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return users;
	}

	@Override
	public User getOne(String id) {
		User user = null;
		try {
			user = userDAO.getOne(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return user;
	}

	@Override
	public void save(User user) {
		try {
			userDAO.insertUser(user);
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}

	@Override
	public void alter(User user) {
		try {
			userDAO.updateUser(user);
		} catch (Exception e) {
			e.printStackTrace();
		}			
	}

	@Override
	public void remove(String id) {
		try {
			userDAO.deleteUser(id);
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}

}
